package com.itcsystem.manager;

import com.itcsystem.connection.ConnectionUtility;
import java.util.ArrayList;
import java.util.List;
import java.sql.*;
import com.itcsystem.struct.Aula;

public class AulaManager{
	private ConnectionUtility connectionUtility = ConnectionUtility.getConnectionUtility();

	public Integer insertAula(Aula aula){
		String sql = "INSERTAULA ?,?";
	
		List<Object> parameters = new ArrayList<Object>();
		parameters.add(aula.getCapacidad());
		connectionUtility.buildPreparedStatement(sql, parameters, true);
		
		return connectionUtility.executeSQLInsert();
	}
	public Boolean deleteAula(int idAula){
		String sql = "DELETEAULA ?";
		connectionUtility.buildPreparedStatement(sql, idAula);
	
		return connectionUtility.executeSQLDelete();
	}
	public List<Aula> getAulas(){
		List<Aula> listAula = new ArrayList<Aula>();
		String sql = "SELECTAULA";
	
		try{
			ResultSet resultSet = connectionUtility.getResult(sql);
		
			if (resultSet !=null){
				while(resultSet.next()){
					Aula obj = new Aula();
		
					obj.setClave((int)resultSet.getObject("Clave"));
	
					obj.setCapacidad((int)resultSet.getObject("Capacidad"));
	
					
					listAula.add(obj);
				}
			}
		}
		catch(SQLException ex){
			ex.printStackTrace();
		}
	
		return listAula;
	}
}
